document.write("<script src='./js/jquery.SuperSlide.2.1.3.source.js'></script>")
document.write("<script src='./js/swiper-bundle.min.js'></script>")
document.write("<script src='./js/wow.min.js'></script>")
document.write("<script src='./js/number.js'></script>")
document.write("<script src='./js/parazoom.min.js'></script>")
document.write("<script src='./js/spotlight.bundle.js'></script>")

window.onload = function () {

    //#region wow.js
    var wow = new WOW({
        boxClass: 'wow', // default
        animateClass: 'animate__animated', // default
        offset: 0, // default
        mobile: true, // default
        live: true // default
    })
    wow.init();
    //#endregion

    var mySwiper = new Swiper('.head_bn_slider', {
      effect: 'fade',
      speed: 1000,
      loop: true,
      fadeEffect: {
        crossFade: true,
      },
      autoplay: {
        delay: 5000,
        disableOnInteraction: false,
      },

      })


    //#region 菜单生产三角号
    // 
    var head_nav = $('.web_nav > ul > li')
    //    var a_nav=$('.web_nav > ul > li > a')
    for (let s = 0; s < head_nav.length; s++) {
        if (head_nav[s].getElementsByTagName("ul").length > 0) {
            var span = document.createElement('b')
            // span.innerHTML="▼"
            // console.log( head_nav[s].childNodes);
            head_nav[s].childNodes[1].append(span);
        }
    }

    var head_nav_2 = $('.web_nav > ul > li> ul >li')
    for (let w = 0; w < head_nav_2.length; w++) {
        if (head_nav_2[w].getElementsByTagName("ul").length > 0) {
            var span = document.createElement('b')
            head_nav_2[w].childNodes[1].append(span);
        }
    }
    //#endregion

    //#region 首页banner
    //    banner
    var mySwiper = new Swiper('.indexPage .bannerWrapper .swiper', {
        //   effect: 'fade',
         loop: true,
         autoplay: {
             delay: 5000,
         },
         slidesPerGroupAuto: false,
         slidesPerView: 'auto',
         slidePerGroup: 1, //每次滑过多少块 
         slidesPerView: 1,


         navigation: {
             nextEl: '.indexPage .bannerWrapper  .swiper-button-next',
             prevEl: '.indexPage .bannerWrapper  .swiper-button-prev',
         },

         pagination: {
             el: '.indexPage .bannerWrapper  .next',
             clickable: true,
         },




         observer: true, //修改swiper自己或子元素时，自动初始化swiper
         observeParents: true, //修改swiper的父元素时，自动初始化swiper
     })
    //#endregion

    //#region 首页触碰切换
    if($('.Wrapper02 ul >li').length>0){
        if(window.innerWidth>950){
            var active =$('.Wrapper02 ul >li')
            active[0].classList.add('active')
            $('.Wrapper02 ul >li').hover(function(){
              if( !$(this).hasClass('active')){
                $('.Wrapper02 ul >li').removeClass('active')
                $(this).addClass('active')
              }
             },function(){
              $(this).addClass('active')
             }) 
          }
          if(window.innerWidth<950){
           
            $('.Wrapper02 ul >li').addClass('active')
          }
    }
   
    //#endregion

    //#region 合作伙伴
    var mySwiper = new Swiper ('.customerswiper', {
        loop: true, // 循环模式选项
        slidesPerView: 2,
        autoplay:true,
        breakpoints: {
         1280: {  //当屏幕宽度小于等于1280
           slidesPerView: 6,
           spaceBetween: 30,
         },
         768: {  //当屏幕宽度小于等于768
           slidesPerView: 5,
           spaceBetween: 20,
         },
        //  320: {  //当屏幕宽度小于等于320
        //    slidesPerView: 3,
        //    spaceBetween: 10,
        //  }
       },
      
      }) 
  //#endregion

     //#region 新闻
var mySwiper2 = new Swiper ('.new_swiper', {
    slidesPerView:1,
    spaceBetween: 10,
    // 如果需要前进后退按钮
    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },
    observer: true, //修改swiper自己或子元素时，自动初始化swiper
    observeParents: true, //修改swiper的父元素时，自动初始化swiper
    breakpoints: {
        //当屏幕宽度大于等于1366
        1200: {
          slidesPerView: 2.6
        },
        480: {
          slidesPerView: 2
        },
       
      },

  })        
  //#endregion

    //#region  aside
    if($('aside').length>0){
        var side = $('.pro_menu>ul>li')   
        var side_2 = $('.pro_menu>ul>li>ul')
        var span=document.createElement('b')
        span.innerHTML="▶"
        side.append(span)
        for (var d = 0; d < side.length; d++) {
            
            var this_li = side[d].closest('li');
           
            if (this_li.getElementsByTagName("ul").length == 0) {
                const this_span = this_li.getElementsByTagName("b")[0];
                this_span.style.display = "none";
                 }

            side[d].onclick = function () {
                if ($(this).find('ul').css('display') == 'none') {
                    side.find('b').css('transform','rotate(0deg)') 
                    side_2.css('display', 'none')
                    $(this).find('ul').slideDown(150)
                    $(this).find('b').css('transform','rotate(90deg)')                    
                } else {
                    $(this).find('ul').slideUp(150)
                    $(this).find('b').css('transform','rotate(0deg)') 
                }
            }
        }
    }
//#endregion

    //#endregion

  //#region  
  var mySwiper = new Swiper ('.module02_swiper', {
    loop: true, // 循环模式选项
    // 如果需要分页器
    pagination: {
      el: '.swiper-pagination',
    },
  })
  if($('.module05Box'))  {
     jQuery(".module05Box").slide({trigger:"click"});  
  }    
 
//#endregion

// 
var mySwiper = new Swiper ('.Page_module02', {
    loop: true, // 循环模式选项
    slidesPerView:1,
    // spaceBetween:30,
    // 如果需要分页器
    breakpoints:{
        960: {
            slidesPerView: 3
          },
    },
    pagination: {
      el: '.swiper-pagination',
    },
    navigation: {
        nextEl: '.Page02-button-prev',
        prevEl: '.Page02-button-next',
      },
  })    

    //#region 产品页swiper
    
    var swiper = new Swiper('.image-additional', {
        slidesPerView: 3,
        spaceBetween: 15,
        pagination: {
          el: '.product-view .swiper-pagination',
          clickable: true,
        },
        navigation: {
          nextEl: '.product-view .swiper-button-next',
          prevEl: '.product-view .swiper-button-prev',
        },
        breakpoints: {
          1366: {
            slidesPerView: 4
          },
          950: {
            slidesPerView: 3
          },
          480: {
            slidesPerView: 1,
            loop: true
          }
        }
      })
      
    //#endregion

     //#region Faq
 if ($('#faq').length > 0) {
    var liList = $('.faq>ul>li')
    var answerList = $('.faq>ul>li>.answer')
    var btext = $('.faq>ul>li>.question>b')
    // 设置第一个b是
    btext[0].classList.add("active");
    // 设置第一个answer是展示状态    
    answerList[0].style.display = 'block';
    // 循环所有问题   
    for (var i = 0; i < liList.length; i++) {
        liList[i].onclick = function () {
            // 如果问题下的答案是关上的
            if ($(this).find('.answer').css('display') == 'none') {
                // 排他 设置所有b都是+
                btext.removeClass('active');
                // 排他 设置所有的答案都是不展示
                answerList.slideUp(150)
                // 当前的b设置成-
                $(this).find('b').addClass('active')
                // 当前的答案设置成展示
                $(this).find('.answer').slideDown(150)
                // $(this).find('.answer').css('display','block')
            } else {
                $(this).find('.answer').slideUp(150)
                $(this).find('b').removeClass('active');
            }
  
        }
    }
  }
  //#endregion

  var relatedSwiper = new Swiper('.goods-may-like .swiper-slider', {
    slidesPerView:2,
    spaceBetween:10,
    speed: 400,
   
    pagination:{
   el:'.product-pagination',
     clickable: true,
    },
    navigation: {
      nextEl: '.navigate_button_next',
      prevEl: '.navigate_button_prev',
    },
    breakpoints: {
      1680: {
        slidesPerView: 4,
        spaceBetween:28,
      },
      1024: {
        slidesPerView: 3,
        spaceBetween:28,
      },
      768: {
        slidesPerView: 2,
        spaceBetween:28,
      },
      480: {
        slidesPerView: 1,
        spaceBetween: 10
      }
    }
  });
  
}
/*side*/
function sideCate(cateEle,siblingsStatus){
    $(cateEle).each(function() {
      if ($(this).find('ul').length ) {
        $(this).addClass('has-child');
        $(this).append("<span class='icon-cate icon-cate-down'></span>")
        $(this).children('.icon-cate').click(function(e) {
          var mEle=$(this).parent('li');
          var mList=$(this).parent('li').children('ul');
          var msiblings=$(this).parent('li').siblings('li');
          if(siblingsStatus==0){
            msiblings.removeClass('li_active');
            msiblings.children('ul').slideUp(150);
            msiblings.children('.icon-cate').removeClass('icon-cate-up').addClass('icon-cate-down');
          }
          if (mList.is(':hidden')) {
            mEle.addClass('li_active');
            mList.slideDown(150);
            $(this).removeClass('icon-cate-down').addClass('icon-cate-up');
          } else {
            mEle.removeClass('li_active');
            mList.slideUp(150);
            $(this).removeClass('icon-cate-up').addClass('icon-cate-down');
          }
          e.stopPropagation();
        })
      }
    }) 
  }
  $(function() {
    // side cate
    sideCate('.side-cate li',0);
    $('.side-cate,.side-cate ul').each(function(){
      if(!$(this).find('ul').length){
        $(this).addClass('cate-type-list');
      }
    })
    var $currentEle=$('.side-widget .side-cate .nav-current');
    if ($currentEle.parents('ul').length > 0 && $currentEle.find('ul').length > 0) {
      $currentEle.parents('ul').show()
      $currentEle.parents('li').addClass("show_li")
      $currentEle.parents('li.show_li').children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up')
      $currentEle.children('ul').show()
      $('.side-widget .side-cate .nav-current ').children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up');
    } else if ($currentEle.parents('ul').length > 0 && $currentEle.find('ul').length < 1) {
      $currentEle.parents('ul').show()
      $currentEle.parents('li').addClass("show_li")
      $currentEle.parents('li.show_li').children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up')
    } else if ($currentEle.parents('ul').length < 1 && $currentEle.find('ul').length > 0) {
      $currentEle.children('ul').show()
      $currentEle.children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up');
    }
  })
  
//#region 表单
function hideMsgPop() { $('.inquiry-pop-bd').fadeOut('fast') }
if ($('body .inquiry-form-wrap').length > 0) {
  var webTop = $('body .inquiry-form-wrap').offset().top - 80
  $('.product-btn-wrap .email,.button,.side_content .side_list .email ,.inquiry_btn').click(function() {
    $("html, body").animate({ scrollTop: webTop }, 1000);
    $(".ad_prompt").show().delay(3000).hide(300);
  })
} else {
  $('.product-btn-wrap .email,.button,.side_content .side_list .email ,.inquiry_btn').click(function() {
    $('.inquiry-pop-bd').fadeIn('fast')
  })
}
$('.inquiry-pop,.product-btn-wrap .email,.button,.side_content .side_list .email ,.inquiry_btn').click(function(e) { e.stopPropagation(); })
$(document).click(function() { hideMsgPop() })
//#endregion

//#region 全局搜索search
  document.documentElement.className = 'js';; (function (window) {
    if (document.querySelector('.web-search')) {
        'use strict'; var mainContainer = document.querySelector('.container'), searchContainer = document.querySelector('.web-search'), openCtrl = document.getElementById('btn-search'), closeCtrl = document.getElementById('btn-search-close'), inputSearch = searchContainer.querySelector('.search-ipt'); function init() { initEvents() } function initEvents() {
            openCtrl.addEventListener('click', function () { if (!searchContainer.classList.contains("search--open")) { openSearch(); } else { closeSearch(); } });
            closeCtrl.addEventListener('click', closeSearch); document.addEventListener('keyup', function (ev) { if (ev.keyCode == 27) { closeSearch() } })
        } function openSearch() { mainContainer.classList.add('main-wrap--move'); searchContainer.classList.add('search--open'); setTimeout(function () { inputSearch.focus() }, 600) } function closeSearch() { mainContainer.classList.remove('main-wrap--move'); searchContainer.classList.remove('search--open'); inputSearch.blur(); inputSearch.value = '' } init()
    }
})(window);
//#endregion


//#region 多语言

$(document).ready(function () {
    $('.change-language .change-language-cont').append("<div class='change-empty'>Untranslated</div>")
    $('.prisna-wp-translate-seo').append("<div class='lang-more'>More Language</div>")
    if ($('body .prisna-wp-translate-seo').length > 0 && $('.change-language .prisna-wp-translate-seo').length < 1) {
        $('.prisna-wp-translate-seo').appendTo('.change-language .change-language-cont')
        if ($('.change-language .change-language-cont .prisna-wp-translate-seo li').length > 0) {
            $('.change-language .change-language-cont .change-empty').hide()
            $('.change-language .change-language-cont .prisna-wp-translate-seo li').each(function (index) {
                if (index > 35) {
                    $(this).addClass('lang-item lang-item-hide')
                    $('.change-language-cont').find('.lang-more').fadeIn()
                } else {
                    $('.change-language-cont').find('.lang-more').fadeOut()
                }
            })
            if ($('.change-language-cont .lang-more').length > 0) {
                $('.change-language-cont .lang-more').click(function () {
                    if ($(this).parents('.change-language-cont').find('.prisna-wp-translate-seo li.lang-item').hasClass('lang-item-hide')) {
                        $(this).parents('.change-language-cont').find('.prisna-wp-translate-seo li.lang-item').removeClass('lang-item-hide')
                        $(this).addClass('more-active').text('×')
                    } else {
                        $(this).parents('.change-language-cont').find('.prisna-wp-translate-seo li.lang-item').addClass('lang-item-hide')
                        $(this).removeClass('more-active').text('More Language')
                    }
                })
            }
        } else {
            $('.change-language .change-language-cont .change-empty').fadeIn()
        }
    }
})
//#endregion

//#region  web导航

var $nav = $('.this_web_head'),
    navTop = $('.web_nav').offset().top,
    headH = $nav.outerHeight(),
    winTop_1 = 0,
    winWidth = $(window).width(),
    winHeight = $(window).height(),
    spr = $('body').height() - $nav.height(),
    holder = jQuery('<div class="head_holder">');
$(window).on('scroll', function () {
    var winTop_2 = $(window).scrollTop();
    holder.css('height', headH);

    if (winTop_2 > headH && winWidth > 980) {
        holder.show().appendTo($nav);
        $nav.addClass('fixed-nav');
        $nav.parents('body').addClass('fixed-body');
        setTimeout(function () { $nav.addClass('fixed-nav-active') });
    } else {
        holder.hide();
        $nav.removeClass('fixed-nav fixed-nav-active');
        $nav.parents('body').removeClass('fixed-body');
    }

    if (winTop_2 > winTop_1 && winWidth > 980) {
        $nav.removeClass('fixed-nav-appear');
    } else if (winTop_2 < winTop_1) {
        $nav.addClass('fixed-nav-appear');
    }
    winTop_1 = $(window).scrollTop();
})
//#endregion

//#region 手机端导航

function mSizeChange() {
    if (window.innerWidth)
        winWidth = window.innerWidth;
    else if ((document.body) && (document.body.clientWidth))
        winWidth = document.body.clientWidth;
    if (window.innerHeight)
        winHeight = window.innerHeight;
    else if ((document.body) && (document.body.clientHeight))
        winHeight = document.body.clientHeight;
    if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
        winHeight = document.documentElement.clientHeight;
        winWidth = document.documentElement.clientWidth;
    }
    if (winWidth <= 930) {
        if ($('.mobile-head-items').length < 1) {
            var mobileService = '<div class="mobile-head-items"><div class="mobile-head-item mobile-head-nav"><div class="title"></div><div class="main-content-wrap side-content-wrap"><div class="content-wrap"></div></div></div><div class="mobile-head-item mobile-head-language"><div class="title"></div><div class="main-content-wrap side-content-wrap"><div class="content-wrap"></div></div></div><div class="mobile-head-item mobile-head-search"><div class="title"></div><div class="main-content-wrap middle-content-wrap"><div class="content-wrap"></div></div></div>'
            $('body').append(mobileService)
            if ($('body .aside').length > 0) {
                $('.mobile-head-items').append('<div class="mobile-head-item mobile-head-aside"><div class="title"></div><div class="main-content-wrap side-content-wrap"><div class="content-wrap"></div></div></div>')
            }
            $('.mobile-head-item').each(function () {
                $(this).find('.title').click(function () {
                    if ($(this).parents('.mobile-head-item').find('.main-content-wrap').length > 0) {
                        var pItem = $(this).parents('.mobile-head-item')
                        if (!pItem.find('.main-content-wrap').hasClass('show-content-wrap')) {
                            pItem.find('.main-content-wrap').addClass('show-content-wrap')
                            pItem.find('.side-content-wrap').stop().animate({ 'left': '0' }, 300)
                            pItem.find('.middle-content-wrap').addClass('middle-show-content-wrap')
                            pItem.find('.side-content-wrap').append("<b class='mobile-ico-close'></b>")
                            pItem.siblings('.mobile-head-item').find('.main-content-wrap').removeClass('show-content-wrap')
                            pItem.siblings('.mobile-head-item').find('.side-content-wrap').stop().animate({ 'left': '-70%' }, 300)
                            pItem.siblings('.mobile-head-item').find('.middle-content-wrap').removeClass('middle-show-content-wrap')
                            pItem.siblings('.mobile-head-item').find('.side-content-wrap .mobile-ico-close').remove()
                            if ($('.mobile-head-items').find('.mobile-body-mask').length < 1) {
                                $('.mobile-head-items').append('<div class="mobile-body-mask"></div>')
                            }
                        }
                        else {
                            pItem.find('.main-content-wrap').removeClass('show-content-wrap')
                            pItem.find('.side-content-wrap').stop().animate({ 'left': '-70%' }, 300)
                            pItem.find('.middle-content-wrap').removeClass('middle-show-content-wrap')
                            pItem.find('.side-content-wrap .mobile-ico-close').remove()
                        }
                        $('.mobile-body-mask').click(function () {
                            $('.mobile-body-mask').remove()
                            $('.mobile-head-item .main-content-wrap').removeClass('show-content-wrap')
                            $('.mobile-head-item .side-content-wrap').animate({ 'left': '-70%' }, 300)
                            $('.mobile-head-item .middle-content-wrap').removeClass('middle-show-content-wrap')
                            $('.mobile-head-item .side-content-wrap .mobile-ico-close').remove()
                        })
                        $('.mobile-ico-close').click(function () {
                            $('.mobile-body-mask').remove()
                            $('.mobile-head-item .main-content-wrap').removeClass('show-content-wrap')
                            $('.mobile-head-item .side-content-wrap').stop().animate({ 'left': '-70%' }, 300)
                            $('.mobile-head-item .middle-content-wrap').removeClass('middle-show-content-wrap')
                            $('.mobile-head-item .side-content-wrap .mobile-ico-close').remove()
                        })
                    }
                })
            })
            $('.change-currency ').clone().appendTo('.mobile-head-item.mobile-head-currency .main-content-wrap .content-wrap')
            $('.change-language .change-language-cont').clone().appendTo('.mobile-head-item.mobile-head-language .main-content-wrap .content-wrap')
            $('.web_nav>ul').clone().appendTo('.mobile-head-item.mobile-head-nav .main-content-wrap .content-wrap')
            $('.head-search:last').clone().appendTo('.mobile-head-item.mobile-head-search .main-content-wrap .content-wrap')
            $('.head_sns').clone().appendTo('.mobile-head-item.mobile-head-social .main-content-wrap .content-wrap')
            $('.aside .aside-wrap').clone().appendTo('.mobile-head-item.mobile-head-aside .main-content-wrap .content-wrap')
        }
    }
    //mobile end
    else {
        $(document).ready(function () {
            $('.mobile-body-mask,.mobile-head-items,.mobile-head-items,.mobile-nav-items,.mobile-cart-items,.mobile-tab-items').remove()
        });
    }
}
$(function () { mSizeChange(); })
$(window).resize(function () { mSizeChange() });

//#endregion

//#region  滚动到头部

var mHeadTop = $('.page_head').offset().top
var $backToTopTxt = "TOP",
    $backToTopEle = $('<span class="gotop"></span>').appendTo($("body"))
        .html('<em>' + $backToTopTxt + '</em>').attr("title", $backToTopTxt).click(function () {
            $("html, body").animate({ scrollTop: 0 }, 600);
        }),
    $backToTopFun = function () {
        var st = $(document).scrollTop(),
            winh = $(window).height();
        (st > mHeadTop) ? $backToTopEle.addClass('active') : $backToTopEle.removeClass('active');
        if (!window.XMLHttpRequest) {
            $backToTopEle.css("top", st + winh - 210);
        }
    };
$(window).bind("scroll", $backToTopFun);
$(function () { $backToTopFun(); });

//#endregion

 //#region 数字跳动
 var window_height = document.documentElement.clientHeight
 var adoutNum = $('.aboutNum')
 var num = document.querySelectorAll('.numadd')
//  console.log(num);
 var slop = false
 window.onscroll = function () {
     if (slop) return
     // 数字跳动
     var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
     if ($('.aboutNum').length > 0) {
         if (scrollTop >= adoutNum.offset().top - window_height && scrollTop <= adoutNum.offset().top) {
            // console.log();
             slop = true
             for (let i = 0; i < num.length; i++) {
                 const numadd = num[i];
                 numadd.classList.add('timer');
                 // 动态数字触发
                 $('.timer').each(count);
                 function count(options) {
                     var $this = $(this);
                     options = $.extend({}, options || {}, $this.data('countToOptions') || {});
                     $this.countTo(options);
                 }
             }
         }
     }
    }
     //#endregion
    